//
//  MonthAxisValueFormatter.swift
//  MYModule
//
//  Created by 李然 on 2022/9/14.
//

import UIKit
import Charts

public class MonthAxisValueFormatter: NSObject, IAxisValueFormatter {
    
    
    public let date:Date
    
    public init(date:Date){
        self.date = date
    }
    
    public func stringForValue(_ value: Double, axis: AxisBase?) -> String {
        let index  = Int(value)
        
        print(index)
        
        if index == 0
            || index == 4
            || index == 9
            || index == 14
            || index == 19
            || index == 24
//            || index == 29
            || index == self.date.monthDays-1 {
            return formatLabel(index)
        }
        return ""
    }
    
    private func formatLabel(_ index:Int) -> String {
        let str = "\(index+1)"
        print(str)
        return str
    }
}
